//南航明珠商城-查看限时统一折扣活动.js


//js去掉空格
function trim(str){
    return  (str+"").replace(/^\s+|\s+$/g,"");
}
function cancle(){
	var index = parent.layer.getFrameIndex(window.name);
	parent.layer.close(index);
}
function auditSuccess(){
	var remark =$.trim($("#remark").val());
	if(remark == '') {
		layer.alert("审核意见为必填项");
		return false;
	}
	layer.confirm("确定审核通过？",function(){
		layer.closeAll('dialog');
		var layer_load_window = layer.load(2); 
		$("#audit_form").ajaxSubmit({
			type:"post",
			url:path+"/activity/audit_success",
			success:function(data){
				var resultArr = data.split(",");
				if(resultArr[0]=="success"){
					layer.msg('操作成功!',{icon:1,time:1000},function(){
						var index = parent.layer.getFrameIndex(window.name);
						parent.$("#search_form").submit();
						parent.layer.close(index);
					});
				}else if(resultArr[0] == "failOne"){
					layer.alert("审核失败,商品"+resultArr[1]+" 已存在于审核通过或已开始的活动中");
		   		 }else{
		   			layer.alert("审核失败，" + resultArr[1]);
		   		}
			},
			error:function(data){
				layer.alert("操作失败!");
			},complete: function(XMLHttpRequest, textStatus) {
				layer.close(layer_load_window);
			}
		});
		
	});
}
function auditFail(){
	var remark =$.trim($("#remark").val());
	if(remark == '') {
		layer.alert("审核意见为必填项");
		return false;
	}
	layer.confirm("确定审核驳回？",function(){
		layer.closeAll('dialog');
		var layer_load_window = layer.load(2); 
		$("#audit_form").ajaxSubmit({
			type:"post",
			url:path+"/product_sale/audit_fail",
			success:function(data){
				var resultArr = data.split(",");
				if(resultArr[0]=="success"){
					layer.msg('操作成功!',{icon:1,time:1000},function(){
						var index = parent.layer.getFrameIndex(window.name);
						parent.$("#search_form").submit();
						parent.layer.close(index);
					});
				}else if(resultArr[0] == "failOne"){
					layer.alert("审核失败,商品"+resultArr[1]+" 已存在于审核通过或已开始的活动中");
		   		 }else{
		   			layer.alert("审核失败，" + resultArr[1]);
		   		}
			},
			error:function(data){
				layer.alert("操作失败!");
			},complete: function(XMLHttpRequest, textStatus) {
				layer.close(layer_load_window);
			}
		});
		
	});
}